<h3>
    <a href="{:U(GROUP_NAME.'/Article/catlist')}" class="actionBtn add">
        返回列表
    </a>
    {$title}
</h3>
<script type="text/javascript">
    $(function(){ $(".idTabs").idTabs(); });
</script>
<div class="idTabs">
    <ul class="tab">
        <li><a href="#info">栏目信息</a></li>
        <li><a href="#cont">栏目内容</a></li>
    </ul>
    <div class="items">
        <form action="{:U(GROUP_NAME.'/Article/addcat')}" method="post">
            <div id="info">
                <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                    <tr>
                        <td align="right">上级分类</td>
                        <td>
                            <select name="pid">
                                <option value="0" >顶级栏目</option>
                                <volist name="catlist" id="vo">
                                    <option value="{$vo.id}" <if condition="$vo['id'] eq $pid">selected</if> >{$vo.name}</option>
                                </volist>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">分类名称</td>
                        <td>
                            <input type="text" name="name" value="" size="30" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">分类别名</td>
                        <td>
                            <input type="text" name="ename" value="" size="30" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">缩略图</td>
                        <td>
                            <input type="text" name="thumbnail" id="thumbnail" value="" size="30" class="inpMain" />
                            <button id="Upload_img" class="btn" type="button">上传</button>
                            <div style="display: none;">
                                <input id="imgFile" type="file" name="imgFile" style="display: none;">
                            </div>
                            <div id="res_show_img" style="display: none;"></div>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">关键字</td>
                        <td>
                            <input type="text" name="keywords" value="" size="50" class="inpMain" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">简单描述</td>
                        <td>
                            <textarea name="description" cols="60" rows="4" class="textArea"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">排序</td>
                        <td>
                            <input type="text" name="sort" value="99" size="5" class="inpMain" />
                        </td>
                    </tr>

                </table>
            </div>
            <div id="cont">
                <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                    <tr>
                        <td>
                            文章内容:
                        </td>
                        <td>
                            <textarea id="content" name="cont" style="width:780px;height:400px;" class="textArea"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
            <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                <tr>
                    <td width="131"></td>
                    <td>
                        <input class="btn" type="submit" value="提交" />
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<link rel="stylesheet" href="__PUBLIC__/main/js/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="__PUBLIC__/main/js/kindeditor/plugins/code/prettify.css" />
<script charset="utf-8" src="__PUBLIC__/main/js/kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="__PUBLIC__/main/js/kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="__PUBLIC__/main/js/kindeditor/plugins/code/prettify.js"></script>
<script>
    //编辑器加载
    KindEditor.ready(function(K) {
        var editor1 = K.create('textarea[name="cont"]', {
            cssPath : '__PUBLIC__/main/js/kindeditor/plugins/code/prettify.css',
            uploadJson : '__PUBLIC__/main/js/kindeditor/php/upload_json.php',
            fileManagerJson : '__PUBLIC__/main/js/kindeditor/php/file_manager_json.php',
            allowFileManager : true,
            afterCreate : function() {
                var self = this;
            }
        });
        prettyPrint();
    });
    //上传缩略图
    $(function (){
        //如果有图片就显示
        if($("#thumbnail").val() != '' && $("#thumbnail").val() != null){
            $("#res_show_img").show();
            $("#res_show_img").html('<img src="'+$("#thumbnail").val()+'" width="150px">');
        }

        $("#Upload_img").click(function (){
            $("#show_Img").html('');
            $("#show_Img").css('display','none');
            $("#imgFile").click();
        });
        $("#imgFile").change(function(){
            $("#Upload_img").html('上传中...');
            var tmp_path = $("#imgFile").val();
            if(tmp_path != '' && tmp_path != null){
                var pic = $('#imgFile')[0].files[0];
                var fd = new FormData();
                fd.append('imgFile', pic);
                $.ajax({
                    url:"__PUBLIC__/main/js/kindeditor/php/upload_json.php",
                    type:"post",
                    dataType:'json',
                    data: fd,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success:function(data){
                        if(data && data.error == '0'){
                            $("#res_show_img").show();
                            var imgurl = data.url;
                            $("#res_show_img").html('<img src="'+imgurl+'" width="150px">');
                            $("#thumbnail").val(imgurl);
                            layer.msg('上传成功');
                        }else{
                            layer.msg('上传出错了...');
                        }
                        $("#Upload_img").html('重新上传');
                    },
                    error:function (){
                        $("#Upload_img").html('重新上传');
                    }
                });
            }
        });
    });
</script>
